var express = require('express');
var router = express.Router();
var { shopModel, groupModel } = require('../../../model/model')
/* GET home page. */
router.get('/', function (req, res, next) {
  // res.render('index', { title: 'Express' });
  res.send('hello world');
});

// 获取商品销量
router.get('/getshop', async (req, res) => {
  let shop = await shopModel.find()
  let data = shop.sort((a, b) => {
    return b.sell - a.sell
  })
  data = data.slice(0, 10)
  res.send({
    code: 200,
    data: data
  })
})

// 获取团长销量
router.get('/getgroup', async (req, res) => {
  let data = await groupModel.find()
  data = data.sort((a, b) => {
    return b.deal_num - a.deal_num
  })
  data = data.slice(0, 10)
  res.send({
    code: 200,
    data: data
  })
})








module.exports = router;
